package com.example.gulimallserch.controller;


import com.example.gulimallserch.service.MallSearchService;
import com.example.gulimallserch.vo.SearchParamVo;
import com.example.gulimallserch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description:
 * @Created: with IntelliJ IDEA.
 * @author: 夏沫止水
 * @createTime: 2020-06-12 18:07
 **/

@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;


    /**
     * 自动将页面提交过来的所有请求参数封装成我们指定的对象
     * @return
     */
    @GetMapping(value = "/list.html")
    public String listPage(SearchParamVo searchParamVo, Model model, HttpServletRequest request) {
        searchParamVo.setParamUrl(request.getQueryString());
        SearchResult searchResult = mallSearchService.goodsSearch(searchParamVo);
        model.addAttribute("result", searchResult);
        return "list";
    }

}
